var nameLine = [];
var valueLine = [];
var cols_arr = [];

$(function() {
    searh();
});

function searh() {
    var myDate = new Date();
    cols_arr = [{'CODE':'G20191010009','DATE':myDate.toLocaleString(),'TIME':myDate.toLocaleString(),'STATUS':'待上架','QT_STATUS':'领夹板'},
        {'CODE':'G20191010008','DATE':myDate.toLocaleString(),'TIME':myDate.toLocaleString(),'STATUS':'上架完成','QT_STATUS':'准备就绪'},
        {'CODE':'G20191010007','DATE':myDate.toLocaleString(),'TIME':myDate.toLocaleString(),'STATUS':'待上架','QT_STATUS':'准备就绪'},
        {'CODE':'G20191010006','DATE':myDate.toLocaleString(),'TIME':myDate.toLocaleString(),'STATUS':'待上架','QT_STATUS':'准备就绪'},
        {'CODE':'G20191010005','DATE':myDate.toLocaleString(),'TIME':myDate.toLocaleString(),'STATUS':'待上架','QT_STATUS':'准备就绪'}];
    renderTable(cols_arr);
    var myChart = echarts.init(document.getElementById('matCheckChart'));
    $("#zhw").html('123'); //总货位数量
    $("#kxhw").html('134');//空闲货位数量
    $("#syhw").html('52');//使用货位数量
    $("#drx").html('461');//待入楦货位数量
    setEchartsPie(myChart, [
        { value: 160, name: '使用数量' },
        { value: 120, name: '空闲数量' }
    ]);

   /*   $.post("<%=request.getContextPath()%>/productLine/search", data, function(res) {
        if(res.result) {
            var myChart = echarts.init(document.getElementById('sevenBroken'));
            pageSet = res.data;
            this.orderList = pageSet.fzjdata.proJobList;//获取作业工单列表数据
            this.sevenData = pageSet.fzjdata.proSevenList;//立体库实时库存查询
            this.ycqkData = pageSet.fzjdata.proExceptionList;//立体库实时库存占比

            renderTable(this.orderList);
            setEchartsPie(myChart,this.sevenData);
            $("#zhw").html(sevenData.ZHW); //总货位数量
            $("#kxhw").html(sevenData.KXHW);//空闲货位数量
            $("#syhw").html(sevenData.SYHW);//使用货位数量
            $("#drx").html(sevenData.DRX);//待入楦货位数量
        } else {
            alert(res.msg);
        }
    }, "json");*/
}
function renderTable(cols_arr){
    if(cols_arr){
        var trHtml = [];
        for(var i in cols_arr) {
            trHtml.push("<tr>");
            trHtml.push("<td align='center' class='addTr_title'>" + cols_arr[i].CODE + "</td>");
            trHtml.push("<td align='center' class='addTr_title'>" + nvl(cols_arr[i].DATE,'') + "</td>");
            trHtml.push("<td align='center' class='addTr_title'>" + cols_arr[i].TIME + "</td>");
            trHtml.push("<td align='center' class='addTr_title'>" + cols_arr[i].STATUS + "</td>");
            trHtml.push("<td align='center' class='addTr_title'>" + cols_arr[i].QT_STATUS + "</td>");
            trHtml.push("</tr>");
        }
        trHtml = trHtml.join("");

        $("#addTr").after(trHtml);
    }

}
function setEchartsPie(id, data) {
    var dataName = [];
    var total = 0;
    data.forEach((res) => {
        dataName.push(res.name);
        total += parseFloat(res.value) * 10000;
    });
    total = total / 10000;
    var option = {

        title: {
            zlevel: 0,
            text:'立体库存实时占比',
            x:"center",
        },
        tooltip: { // 悬停指示
            trigger: 'item',
            formatter: "{b}: {c} ({d}%)"
        },
        legend: {
            orient: 'vertical',
            x: 'right',
            data: dataName,
            itemGap: 30,
            top: 'middle',
            align: 'left',
            icon: 'circle',
            formatter: function (name) {
                return name;
            }
        },
        series: [
            {
                name: '访问来源',
                type: 'pie',
                radius: ['80%', '84%'],
                center: ['50%', '50%'],
                stillShowZeroSum: false,
                avoidLabelOverlap: false,
                zlevel: 1,
                label: {
                    normal: {
                        padding: [30, 30, 30, 30],
                        backgroundColor: '#fff',
                        show: false,
                        position: 'center',
                        formatter: [
                            '{value|{c}}',
                            '{name|{b}}'
                        ].join('\n'),
                        rich: {
                            value: {
                                color: '#303133',
                                fontSize: 40,
                                fontWeight: 'bold',
                                lineHeight: 40,
                            },
                            name: {
                                color: '#909399',
                                lineHeight: 20
                            },
                        },
                    },
                    emphasis: {
                        show: true,
                        textStyle: {
                            fontSize: '16',
                            fontWeight: 'bold'
                        }
                    }
                },
                data: data
            }
        ],
        color: ['#410ADF','#F42850','#F6A93B','#7ED321','#282828']
    };
    id.setOption(option);
}
